﻿using OA.IBLL;
using OA.ViewModels.Persons;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace OA.Mvc.Controllers
{
    public class PersonController : Controller
    {
        public ISysPersonService PersonService { get; set; }
        // GET: Person
        public async Task<ActionResult> Index(string name="",int pageIndex=1)
        {
            int total;
            var list=await PersonService.GetList(p => p.Name.Contains(name), pageIndex, 10, out total, x => x.Id)
                .Select(p => new ListPerson() { Id = p.Id, Name = p.Name, LoginState = p.LoginState, State = p.State, Phone = p.Phone })
                .ToListAsync();
                
            return View(list);
        }
    }
}